﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" 
Inherits="System.Web.Mvc.ViewPage<MvcCmsForum.Models.ViewData.ForumModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%=ViewData["PageTitle"]%>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
    <style type="text/css">
        label.error
        {
            float: none;
            color: red;
            padding-left: .5em;
            vertical-align: top;
        }
    </style>
    <link href="/content/app_themes/<%=ViewData["SkinName"] %>/css/Forum.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <div class="spacer_top">
        </div>
        <div id="thecontent" class="thecontent">
            <h2>
                <a href="/forums">Forums Home</a></h2>
            <h2>
                <%=Html.Encode(Model._Forum.Title) %>
                Forum</h2>
            <%= Html.ActionLink("Create A Post For This Forum", "CreatePost", new { forumId = Model._Forum.ForumID }, new { @class = "post-button" })%>
            <span class="field-validation-error">&nbsp;
                <%=ViewData["message"].ToString()%>
            </span>
            <% if (Model._Posts.Count() == 0)
               { %>
            <p>
                There are no posts in this forum yet, you can be the first.</p>
            <% }
               else
               { %>
            <div id="posts">
                <% foreach (var post in Model._Posts)
                   { %>
                <div id="post-<%= post.PostID %>" class="post">
                    <% if (User.IsInRole("Editor"))
                       { %>
                    <div class="admin">
                        <% if (!post.Closed)
                           { %>
                        <a class="close" meta:id="<%= post.PostID %>" href="#close">Close</a>&nbsp;|&nbsp;
                        <% } %>
                        <a class="remove" meta:id="<%= post.PostID %>" href="#remove">Remove</a>
                    </div>
                    <% } %>
                    <div class="stats">
                        <div class="votes stat">
                            <strong>
                                <%= post.VoteCount %></strong><small>votes</small></div>
                        <div class="replies stat">
                            <strong>
                                <%= post.ReplyCount %></strong><small>replies</small></div>
                        <div class="views stat">
                            <strong>
                                <%= post.ViewCount %></strong><small>views</small></div>
                    </div>
                    <h3>
                        <a href="/forums/forum-<%=Html.Encode(post.Forum.Path) %>/<%=Html.Encode(post.Path) %>">
                            <%=Html.Encode(post.Title) %></a> -<%=post.ThreadUser.UserName.ToProfileLink()%>
                        <% if (post.Closed)
                           { %>
                        [closed]
                        <% } %>
                    </h3>
                    <div class="posted-last">
                        <span class="posted-at">last post - 
                            <%= post.LastPostDate.ToUtcTimeSinceString() %>
                            ago</span> <span class="posted-by">by
                                <img src="<%= post.LastPostByAvatarUrl %>" />
                                <%= post.ReplyUser.UserName.ToProfileLink() %></span>
                    </div>
                </div>
                <hr />
                <% } %>
            </div>
            <% Html.RenderPartial("ControlsForum/ForumPager", Model._Posts); %>
            <% } %>
        </div>
    </div>
</asp:Content>
<asp:Content ID="SidebarContent" ContentPlaceHolderID="SidebarContent" runat="server">
    <% Html.RenderPartial("ControlsForum/AdminSidebar"); %>
</asp:Content>
<asp:Content ID="ScriptContent" ContentPlaceHolderID="ScriptContent" runat="server">
<script src="/Scripts/MvcCms.js" type="text/javascript"></script>
<script type="text/javascript" >
    LoadRecentPosts();
</script>
    <% if (User.IsInRole("Admin"))
       { %>

    <script type="text/javascript" src="/Areas/MvcCmsForum/scripts/manage-forums.js"></script>

    <% } %>
</asp:Content>
